from django.shortcuts import render
from testdemo import models
from django.core.paginator import Paginator,Page,PageNotAnInteger

def test1(request):
    ret = models.T_newsTables.objects.all().filter(emotion=1)

    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # try:
    #     posts = paginator.page(current_page)
    # except PageNotAnInteger as e:
    #     posts = paginator.page(1)
    # return render(request, 'test1.html', {'headline_list': posts,
    #                                       })
    return render(request, 'test1.html', {'headline_list': ret,
                                          })


def test2(request):
    ret = models.T_newsTables.objects.all().filter(emotion=0)
    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # try:
    #     posts = paginator.page(current_page)
    # except PageNotAnInteger as e:
    #     posts = paginator.page(1)
    #
    # return render(request, 'test1.html', {'headline_list': posts,
    #                                       })


    return render(request, 'test1.html', {'headline_list': ret,
                                      })


def test3(request):

    ret = models.T_newsTables.objects.all().filter(emotion=2)

    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # try:
    #     posts = paginator.page(current_page)
    # except PageNotAnInteger as e:
    #     posts = paginator.page(1)
    #     return render(request, 'test1.html', {'headline_list': posts,
    #                                       })
    return render(request, 'test1.html', {'headline_list': ret,
                                          })
# Create your views here.
